package cn.hp.util;

import com.alibaba.fastjson.JSON;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class ReturnJsonData {

    public static void returnJson(Object obj, HttpServletResponse res){
        String s = JSON.toJSONString(obj);
        PrintWriter pw =  null;

        try {
            pw = res.getWriter();
            pw.write(s);
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if(pw!=null)pw.close();
        }

    }

}
